//
//  BKUserPersonalInfoTexImgCell.m
//  bestkeep
//
//  Created by windCould on 16/11/29.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKUserPersonalInfoTexImgCell.h"
#import "BKMyCommon.h"
#import "CellModel.h"
@interface BKUserPersonalInfoTexImgCell ()

@property (nonatomic,strong)UILabel * mainTitleLab;
@property (nonatomic,strong)UIImageView * userLogoImgV;
@property (nonatomic,strong)UIImageView * arrowImgV;
@property (nonatomic,strong)UIView  * bottomLineView;

@end



@implementation BKUserPersonalInfoTexImgCell


+(instancetype)cellWithTableview:(UITableView *)tableview
{
    BKUserPersonalInfoTexImgCell * cell = [tableview dequeueReusableCellWithIdentifier:BKUserInfoTextHeadViewCell];
    if (cell == nil) {
        
        cell = [[BKUserPersonalInfoTexImgCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BKUserInfoTextHeadViewCell];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}


#pragma mark =========================Function===============================

-(void)fillData:(id)data
{
    CellModel  * model = data;
    if (![model.image isEqualToString:@""] || model.image != nil) {
        
        [_userLogoImgV load:model.image placeholderImage:[UIImage imageNamed:@"BK_My_default_head"]];
    } else {
        
        _userLogoImgV.image = [UIImage imageNamed:@"BK_My_default_head"];
    }
    
    _mainTitleLab.text = model.title;
}

#pragma mark =========================布局===================================

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setUpViews];
    }
    
    return  self;
}


-(void)setUpViews{
    
    _mainTitleLab = [UILabel new];
    _mainTitleLab.textColor = BK_MY_COLOR_07;
    _mainTitleLab.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_mainTitleLab];

    _userLogoImgV  = [[UIImageView alloc]initWithFrame:CGRectZero];
    _userLogoImgV.layer.cornerRadius = 15;
    _userLogoImgV.layer.masksToBounds = YES;
    [self.contentView addSubview:_userLogoImgV];
    
    _arrowImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
    _arrowImgV.image = [UIImage imageNamed:@"BK_My_LeftArrow"];
    _arrowImgV.contentMode =  UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:_arrowImgV];
    
    _bottomLineView = [[UIView alloc]initWithFrame:CGRectZero];
    _bottomLineView.backgroundColor = RGBCOLOR(231, 232, 233, 1);
    [self.contentView addSubview:_bottomLineView];
    
    [self layoutViews];
}


-(void)layoutViews{
    
    [_mainTitleLab  mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(ApplicationBackGauge);
        make.height.mas_equalTo(@(20));
    }];
    
    [_userLogoImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.right.mas_equalTo(_arrowImgV.mas_left).offset(-6);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    
    
    [_arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge+2);
        make.size.mas_equalTo(CGSizeMake(15,15));
    }];
    
    [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(@(0.5));
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
    }];
    
}





@end
